/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package GUI;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.SQLException;
import javax.swing.JOptionPane;

/**
 *
 * @author jony
 */
public class JPCrearHistorialClinico extends javax.swing.JPanel {

    /**
     * Creates new form JPCrearHistorialClinico
     */
    public JPCrearHistorialClinico() {
        initComponents();
        
        //TOOLTIP
       jtfDireccion.setToolTipText("Escribe aquí la direccín del paciente. Por ejemplo. C/Galicia, Nº4, Bajo B");
       jtfDni.setToolTipText("Escribe aquí el DNI del paciente. Por ejemplo.86559658F");
       jtfFechaHoy.setToolTipText("Escribe la fecha de hoy. Por ejemplo. 20/02/2015");
       jtfNombre.setToolTipText("Escribe aquí el nombre del paciente. Por ejemplo. Jonatan");
       jtfTelefono.setToolTipText("Escribe aquí el teléfono del paciente. Por ejemplo. 699699669");
        
        
         //Pongo todos los TextField para que se pueda escribir
        jtfDireccion.setEditable(true);
        jtfDni.setEditable(true);
        jtfFechaHoy.setEditable(true);
        jtfNombre.setEditable(true);
        jtfTelefono.setEditable(true);
        
        
        /**
         * Botón Guardar Historial clinico
         * Una vez que haya rellenado los campos pulsaré este botón para guardarlo en la bbdd
         */
          jbGuardarHistorialClinico.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {

                int telefono = Integer.parseInt(jtfTelefono.getText());
                String direccion = jtfDireccion.getText();
                String dni = jtfDni.getText();
                String fecha = jtfFechaHoy.getText();
                String nombre = jtfNombre.getText();


                   int codigo=JOptionPane.showConfirmDialog(null, "¿Quieres añadir un nuevo historial clínico?", "HISTORIAL CLINICO", JOptionPane.YES_NO_OPTION, JOptionPane.PLAIN_MESSAGE);
                   if (codigo==JOptionPane.YES_OPTION){
                     System.out.println("Has pulsado en SI");
                  }else if(codigo==JOptionPane.NO_OPTION){
                     System.out.println("Has pulsado en NO");
                  }
                   
                   //lo comento porque todavía no está la base de datos
                   
//                Modelo nModelo;
//                nModelo = new Modelo(id ,jtfModelo.getText(), consumo, emisiones,jtfce.getText());
//                bbdd dbm = null;
//                try {
//                    dbm = new bbdd();
//                    dbm.addModelo(nModelo);
//                    System.out.println("MODELO CREADA");
//
//                } catch (ClassNotFoundException ex) {
//                    System.err.println("DRIVER NO ENCONTRADO.");
//                    ex.printStackTrace();
//                } catch (SQLException ex) {
//                    System.err.println("SQLEXCEPTION.");
//                    ex.printStackTrace();
//                } finally {
//                    if (dbm != null) {
//                        try {
//                            dbm.closeConnection();
//                        } catch (SQLException exc) {
//                            System.err.println("SQLEXCEPTION DURANTE EL CIERRE.");
//                            exc.printStackTrace();
//                        }
//                    }
//                }
            }
        });
        
    }

    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        jbGuardarHistorialClinico = new javax.swing.JButton();
        jLabel1 = new javax.swing.JLabel();
        jLabel2 = new javax.swing.JLabel();
        jLabel3 = new javax.swing.JLabel();
        jLabel4 = new javax.swing.JLabel();
        jLabel5 = new javax.swing.JLabel();
        jLabel6 = new javax.swing.JLabel();
        jtfNombre = new javax.swing.JTextField();
        jtfDireccion = new javax.swing.JTextField();
        jtfDni = new javax.swing.JTextField();
        jtfFechaHoy = new javax.swing.JTextField();
        jtfTelefono = new javax.swing.JTextField();

        setPreferredSize(new java.awt.Dimension(800, 600));

        jToolBar1.setRollover(true);

        jbGuardarHistorialClinico.setIcon(new javax.swing.ImageIcon(getClass().getResource("/Imagenes/guardar.png"))); // NOI18N
        jbGuardarHistorialClinico.setFocusable(false);
        jbGuardarHistorialClinico.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        jbGuardarHistorialClinico.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(jbGuardarHistorialClinico);

        jLabel1.setFont(new java.awt.Font("Orator Std", 1, 36)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(102, 102, 102));
        jLabel1.setText("CREAR HISTORIAL CLÍNICO");

        jLabel2.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel2.setText("Nombre del cliente:");

        jLabel3.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel3.setText("DNI:");

        jLabel4.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel4.setText("Teléfono:");

        jLabel5.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel5.setText("Dirección:");

        jLabel6.setFont(new java.awt.Font("Verdana", 1, 14)); // NOI18N
        jLabel6.setText("Fecha de hoy:");

        jtfDni.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jtfDniActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(35, 35, 35)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(layout.createSequentialGroup()
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel4)
                                    .addComponent(jLabel3))
                                .addGap(80, 80, 80)
                                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                                    .addComponent(jtfDni, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                    .addComponent(jtfTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE))
                                .addGap(55, 55, 55)
                                .addComponent(jLabel6))
                            .addGroup(layout.createSequentialGroup()
                                .addComponent(jLabel2)
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addComponent(jtfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, 129, javax.swing.GroupLayout.PREFERRED_SIZE)
                                .addGap(55, 55, 55)
                                .addComponent(jLabel5)))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                            .addComponent(jtfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jtfFechaHoy, javax.swing.GroupLayout.PREFERRED_SIZE, 153, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addGap(84, 84, 84)
                        .addComponent(jLabel1))
                    .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 83, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(155, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(36, 36, 36)
                .addComponent(jLabel1)
                .addGap(67, 67, 67)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jtfNombre, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel5)
                    .addComponent(jtfDireccion, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(50, 50, 50)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jtfDni, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel6)
                    .addComponent(jtfFechaHoy, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(54, 54, 54)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel4)
                    .addComponent(jtfTelefono, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(236, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void jtfDniActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jtfDniActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_jtfDniActionPerformed


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JButton jbGuardarHistorialClinico;
    private javax.swing.JTextField jtfDireccion;
    private javax.swing.JTextField jtfDni;
    private javax.swing.JTextField jtfFechaHoy;
    private javax.swing.JTextField jtfNombre;
    private javax.swing.JTextField jtfTelefono;
    // End of variables declaration//GEN-END:variables
}
